package com.rong.maven01demo.control;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {


    @RequestMapping({"/index","/index1"})
    public String index(){
        return "index.html";
    }

    @RequestMapping("/toLogin")
    public String toLogin() {
        return "views/login.html";
    }

    @PostMapping("/submit")
    public String submit() {
//        // 这里使用Spring Security的AuthenticationManager来验证用户凭证
//        Authentication authentication = authenticationManager.authenticate(
//                new UsernamePasswordAuthenticationToken(request.getParameter("username"), request.getParameter("password")));
//
//        SecurityContextHolder.getContext().setAuthentication(authentication);
//        StandardContext context = new StandardContext();
//
//        ApplicationSessionCookieConfig sessionCookieConfig = new ApplicationSessionCookieConfig(context);
//        Cookie cookie = sessionCookieConfig.createSessionCookie(context,request.changeSessionId(),true);
//        response.addCookie(cookie);
        return "views/index.html";
    }
}
